﻿using BootstrapBlazor.Components;
using BPM.Web.Shared.Data;
using BPM.Web.Shared.Dependencies;
using BPM.Web.Shared.Extensions;
namespace BPM.Web.Shared.Service;

[Scoped(typeof(ISysNoticeService))]
public class SysNoticeService : BaseService, ISysNoticeService
{
    private readonly INoticeClient _client;
    public SysNoticeService(INoticeClient client, ToastService toast) : base(toast)
        => _client = client;

    public Task<QueryData<SysNotice>> PageAsync(NoticePageInput input)
        => QueryAsync(_client.PageAsync(input));

    public Task<bool> AddAsync(SysNotice input)
        => ExecuteAsync(_client.AddAsync(input.Adapt<AddNoticeInput>()));

    public Task<bool> DeleteAsync(IEnumerable<SysNotice> input)
        => DeleteAsync(input.Adapts<SysNotice, DeleteNoticeInput>().Select(x => _client.DeleteAsync(x)));

    public Task<bool> EditAsync(SysNotice input)
        => ExecuteAsync(_client.EditAsync(input.Adapt<UpdateNoticeInput>()));

    public Task<SysNotice?> DetailAsync(SysNotice input)
        => QueryAsync(_client.DetailAsync(input.Adapt<QueryNoticeInput>()));

    public Task<bool> ChangeStatusAsync(SysNotice input)
        => ExecuteAsync(_client.ChangeStatusAsync(input.Adapt<ChangeStatusNoticeInput>()));

    public Task<QueryData<SysNotice>> ReceivedAsync(NoticePageInput input)
        => QueryAsync(_client.ReceivedAsync(input));

    public Task<QueryData<SysNotice>> UnreadAsync(NoticeInput input)
        => QueryAsync(_client.UnreadAsync(input));
}

